<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">
<title>Edit staff details</title>
<SCRIPT TYPE="text/javascript" src= "../../commonutils/util/util.js"> </SCRIPT>
</head>
<style type="text/css">
th {text-align: right}
</style>
<body>
<?php include 'top.html' ?>
<?php include '../../authorization_check.php'; ?>
<?php include '../../checkRootOnly.php' ?>

<?php
  session_start();
?>
<?php

	require_once '../../commonutils/db/DBConnectionManager.php';
	
	$ss = "select * from user";
	$rr = DBConnectionManager::query($ss);
	if(mysql_num_rows($rr) != 0)
	{
		echo "<div>";
		echo "<center>";
		echo "<p>Select&nbsp;the&nbsp;user&nbsp;to&nbsp;be&nbsp;deleted</p>";
		echo "<form method=\"POST\" action=\"DeleteUser.php\">";
		echo "<select name=\"selectUser\">";
		while($rrr = mysql_fetch_assoc($rr))
		{
			echo "<option value=\"".$rrr['userName']."\">".$rrr['userName']."</option>";
		}
		echo "</select>";
		echo "<input type=\"submit\" value=\"Delete\" name=\"btnDelete\">&nbsp;&nbsp;";
		echo "</form>";
		echo "</center>";
		echo "</div>";
	
	}
	else
	{
		echo "<center><h4>No user found in database!!!</h4></center>";
	}
	
	if(isset($_POST['btnDelete']))
	{
		$sql = "delete from user where userName='".$_POST['selectUser']."'";
		DBConnectionManager::query($sql);
		echo "<center><h4>Deleted user successfully</h4></center>";
	}
	echo "<center><h1>User Info</h1></center>";
	echo "<center><table border=\"1\" width=\"71%\" id=\"table1\">";
	echo "<tr>";
	echo "<td width=\"95\">User Name</td>";
	echo "<td width=\"65\">First Name</td>";
	echo "<td width=\"126\">Last Name</td>";
	echo "<td width=\"224\">User Type</td>";
	echo "<td width=\"224\">Program Code</td>";
	echo "</tr>";
	
	

	$sqlquery = "select * from user";
	
	$result = DBConnectionManager::query($sqlquery);
	while($row = mysql_fetch_assoc($result))
	{
		echo "<td width=\"95\">".$row['userName']."</td>";
		echo "<td width=\"65\">".$row['firstName']."</td>";
		echo "<td width=\"126\">".$row['lastName']." ".$row['lName']."</td>";
		echo "<td width=\"224\">".$row['userType']."</td>";
		echo "<td width=\"224\">".$row['programCode']."</td>";
		echo "</tr>";
	}	
	echo "</table>";
	echo "</center>";
?>

<br>
<hr color="blue">
<p>
  <a href="../../SecurityIndex.php">Back</a>
</p>
</body>
</html>